Fix | App-of-apps children honor --redirect-target-revisions (#446)#447
Merged
dag-andersen merged 2 commits intoJun 20, 2026
Conversation
…ersen#446) During --traverse-app-of-apps expansion, child Applications/ApplicationSets discovered in rendered manifests were patched with redirectRevisions=nil. An empty list means "redirect everything", so the --redirect-target-revisions filter was silently ignored for children: a child source pinned to a ref not in the list (e.g. a feature branch holding value files absent from the base branch) was still redirected to the PR/base branch and failed to render, failing the whole run. Thread the configured redirectRevisions from RenderApplicationsFromBothBranchesWithAppOfApps through renderAppWithChildDiscovery to every child PatchApplication call so children go through the same RedirectSources/RedirectGenerators filter as seed Applications. Extract the single-Application child patching into a buildChildApplication helper and cover the threading with unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop a redundant inline sentence (the rationale lives on the buildChildApplication doc) and condense the new test section header to match the existing single-line section headers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #446.
With
--traverse-app-of-apps+--render-method=repo-server-api, child Applications discovered during traversal were always redirected to the base/target branch, regardless of--redirect-target-revisions. The flag was only honored for top-level (seed) Applications.Root cause
--redirect-target-revisionsis honored inRedirectSources/RedirectGenerators:But during traversal, children were patched with
redirectRevisions = nilinrenderAppWithChildDiscovery(pkg/reposerverextract/appofapps.go).nil→len(redirectRevisions) == 0→shouldRedirect = truefor every child source, so the filter never applied to traversed children.When a child source is pinned to a ref that isn't in the list (e.g. a feature branch holding Helm value files absent from the base branch), it was redirected to the PR/base branch and failed to render — failing the whole run.
Fix
Thread the configured
redirectRevisionsfromRenderApplicationsFromBothBranchesWithAppOfAppsthroughrenderAppWithChildDiscoveryto every childPatchApplicationcall (the Application case, the ApplicationSet pre-expansion patch, and each ApplicationSet-generated Application). Children now go through the sameRedirectSources/RedirectGeneratorsfilter as seed Applications.The single-Application child patching is extracted into a small
buildChildApplicationhelper, which is covered by unit tests.Behavior change
--redirect-target-revisions→ left untouched, fetched from its real ref (previously: always redirected).--redirect-target-revisionsconfigured → every matching source still redirected (unchanged default).Testing
pkg/reposerverextract/appofapps_test.go:TestBuildChildApplication_LeavesUnlistedRevisionUntouchedTestBuildChildApplication_RedirectsListedRevisionTestBuildChildApplication_EmptyListRedirectsAllgo build ./...,go vet, andgo test ./pkg/reposerverextract/ ./pkg/argoapplication/ ./cmd/all pass.Also documents the behavior in
docs/app-of-apps.md.